package com.elder.web.controller.business;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.NotNull;

import com.elder.business.domain.ReceptionNotice;
import com.elder.business.domain.ReceptionNoticeDTO;
import com.elder.business.service.IReceptionNoticeService;
import com.elder.common.annotation.Anonymous;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.elder.common.annotation.Log;
import com.elder.common.core.controller.BaseController;
import com.elder.common.core.domain.AjaxResult;
import com.elder.common.enums.BusinessType;
import com.elder.common.utils.poi.ExcelUtil;
import com.elder.common.core.page.TableDataInfo;

/**
 * 接待通知Controller
 * 
 * @author elder
 * @date 2024-03-13
 */
@RestController
public class ReceptionNoticeController extends BaseController
{
    @Autowired
    private IReceptionNoticeService receptionNoticeService;

    /**
     * 某个员工的查询接待通知列表
     */
    @Anonymous
    @GetMapping("/business/notice/list")
    public TableDataInfo list(@NotNull Long userId, String elderName, String startTime, String endTime, Integer pageNum, Integer pageSize)
    {
        return receptionNoticeService.selectReceptionNoticeList(userId,elderName,startTime,endTime,pageNum,pageSize);
    }

    /**
     * 获取接待通知详细信息
     */
    @Anonymous
    @GetMapping(value = "/business/notice/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(receptionNoticeService.selectReceptionNoticeById(id));
    }

    /**
     * 新增接待通知
     */
    @Anonymous
    @Log(title = "接待通知", businessType = BusinessType.INSERT)
    @PostMapping("/business/notice")
    public AjaxResult add(@RequestBody ReceptionNotice receptionNotice)
    {
        return toAjax(receptionNoticeService.insertReceptionNotice(receptionNotice));
    }

    /**
     * 修改接待通知
     */
    @Anonymous
    @Log(title = "接待通知", businessType = BusinessType.UPDATE)
    @PutMapping("/business/notice")
    public AjaxResult edit(@RequestBody ReceptionNotice receptionNotice)
    {
        return toAjax(receptionNoticeService.updateReceptionNotice(receptionNotice));
    }

    @Anonymous
    @Log(title = "接待通知", businessType = BusinessType.UPDATE)
    @PutMapping("/business/notice/state")
    public AjaxResult update(@RequestBody ReceptionNoticeDTO receptionNotice)
    {
        return toAjax(receptionNoticeService.updateReceptionNoticeState(receptionNotice));
    }

    /**
     * 删除接待通知
     */
    @Anonymous
    @Log(title = "接待通知", businessType = BusinessType.DELETE)
	@DeleteMapping("/business/notice/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(receptionNoticeService.deleteReceptionNoticeByIds(ids));
    }
}
